package com.ciwong.epaper.util;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.ciwong.epaper.modules.epaper.bean.Answer;
import com.ciwong.epaper.modules.epaper.bean.Module;
import com.ciwong.epaper.modules.epaper.bean.WorkAnswers;
import com.ciwong.epaper.modules.evaluate.bean.AnswerRecorder;
import com.ciwong.epaper.modules.evaluate.bean.RepeatAnswerInfo;
import com.ciwong.epaper.modules.evaluate.bean.WordDetail;
import com.ciwong.epaper.modules.evaluate.ui.RereadWordResultActivity;
import com.ciwong.epaper.modules.me.bean.RequirementContent;
import com.ciwong.epaper.modules.me.bean.WorkContents;
import com.ciwong.epaper.ui.DialogActivity;
import com.ciwong.epaper.ui.GuideActivity;
import com.ciwong.epaper.ui.MainActivity;
import com.ciwong.epaper.ui.NewLoginActivity;
import com.ciwong.epaper.ui.RegisterActivity;
import com.ciwong.epaper.util.download.DownLoadInfo;
import com.ciwong.mobilelib.utils.BaseJumpManager;

import java.io.Serializable;
import java.util.ArrayList;

/**
 * ${todo} Description of class。
 * <p>
 * ${todo} Detail Description
 * <p>
 * ${todo} Sample Code
 * <p>
 * <pre>
 * </pre>
 *
 * @author bin
 * @version ciwong v.1.0 2015/7/25 9:53
 * @since ciwong v.1.0
 */
public class EJumpManager extends BaseJumpManager {
    /**
     * 跳转到注册账号
     *
     * @param goBackId 返回按钮的文字id
     * @param act      启动activity
     * @param
     */
    public static void jumpToRegister(int goBackId, Activity act, String verityCode, String phonenumber) {
        Intent intent = getBaseIntent(goBackId, act, RegisterActivity.class);
        intent.putExtra(IntentFlag.INTENT_FLAG_STR, phonenumber);
        intent.putExtra(IntentFlag.INTENT_FLAG_SMS, verityCode);
        act.startActivity(intent);
    }

    /**
     * 跳转到主界面
     *
     * @param goBackId 返回按钮的文字id
     * @param act      启动activity
     */
    public static void jumpToMain(int goBackId, Activity act) {
        if (!act.isFinishing()) {
            Intent intent = getBaseIntent(goBackId, act, MainActivity.class);
            act.startActivity(intent);
        }
    }

    public static void jumpToLogin(int goBackId, Activity act) {
        if (!act.isFinishing()) {
            Intent intent = getBaseIntent(goBackId, act, NewLoginActivity.class);
            act.startActivity(intent);
        }
    }

    //跳转到单词重读提交结果页面
    public static void jumpToRereadWordResultActivity(int goBackId, Activity act, RequirementContent requirementContent,
                                                      ArrayList<WorkAnswers<RepeatAnswerInfo>> userAnswersList,
                                                      ArrayList<AnswerRecorder> answerRecorders, ArrayList<WordDetail> words, String uuid,
                                                      Answer answer, DownLoadInfo mDownLoadInfo, Module mModule, int position, final WorkContents workContent, int readmode, int requestCodeFrom,long effectiveDate,boolean isKaoShiMode,boolean isShouDongMode) {
        if (!act.isFinishing()) {
            Intent intent = getBaseIntent(goBackId, act, RereadWordResultActivity.class);
            Bundle mBundle = new Bundle();
            mBundle.putSerializable(IntentFlag.INTENT_FLAG_WORDSLIST, (Serializable) words);
            mBundle.putSerializable(IntentFlag.INTENT_FLAG_USERANSWERLIST, (Serializable) userAnswersList);
            mBundle.putSerializable(IntentFlag.INTENT_FLAG_USERANSWERROCORD, (Serializable) answerRecorders);
            mBundle.putSerializable(IntentFlag.INTENT_FLAG_ANSWER, answer);
            mBundle.putSerializable(IntentFlag.INTENT_FLAG_DOWNLOAD_INFO, mDownLoadInfo);
            mBundle.putSerializable(IntentFlag.INTENT_FLAG_MODULE, mModule);
            intent.putExtra(IntentFlag.INTENT_FLAG_OBJ, mBundle);
            intent.putExtra(IntentFlag.INTENT_FLAG_POSITION, position);
            intent.putExtra(IntentFlag.INTENT_FLAG_UUID, uuid);
            intent.putExtra(IntentFlag.INTENT_FLAG_READMODLE, readmode);
            intent.putExtra(IntentFlag.INTENT_FLAG_REQUEST_CODE_FROM, requestCodeFrom);
            intent.putExtra(IntentFlag.INTENT_FLAG_REQU_CONTENT,
                    requirementContent);
            intent.putExtra(IntentFlag.INTENT_FLAG_IS_KAOSHI_MODE,isKaoShiMode);
            intent.putExtra(IntentFlag.INTENT_FLAG_IS_SHOUDONG_MODE,isShouDongMode);
            intent.putExtra(IntentFlag.INTENT_FLAG_WORK_EFFECTIV_TIME,effectiveDate);
            if (null != workContent) {
                intent.putExtra(IntentFlag.INTENT_FLAG_WORK_CONTENTS, workContent);
            }
            act.startActivity(intent);
        }
    }


    /**
     * 跳转到弹框
     *
     * @param act
     */
    public static void jumpToDialogActivity(Activity act) {
        if (act != null && !act.isFinishing()) {
            Intent intent = getBaseIntent(0, act, DialogActivity.class);
            act.startActivity(intent);
        }
    }


    /**
     * 跳转到引导页面
     *
     * @param goBackId
     * @param context
     */
    public static void jumpToGuide(int goBackId, Activity context) {
        Intent intent = getBaseIntent(goBackId, context, GuideActivity.class);
        context.startActivity(intent);

    }
}
